using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using Zwms.Data.BusinessObjects;
using Zwms.Data.Base;
using Zwms.Data.CommonObject;
using NHibernate.Criterion;
using System.Reflection;

namespace Zwms.Data.ManagerObjects
{
    public partial interface IBilPickBillDetailManager : IManagerBase<Zwms.Data.BusinessObjects.BilPickBillDetail, string>
    {
        // Get Methods
        BilPickBillDetail GetById(System.String pickBillCode, System.String stockCode, System.String planGoodsCode);
    }

    partial class BilPickBillDetailManager : ManagerBase<Zwms.Data.BusinessObjects.BilPickBillDetail, string>, IBilPickBillDetailManager
    {
        #region Constructors

        public BilPickBillDetailManager()
            : base()
        {
        }
        public BilPickBillDetailManager(INHibernateSession session)
            : base(session)
        {
        }

        #endregion

        #region Get Methods

        public override BilPickBillDetail GetById(string id)
        {
            string[] keys = id.Split('^');

            if (keys.Length != 3)
                throw new Exception("Invalid Id for BilPickBillDetailManager.GetById");

            return GetById(keys[0], keys[1], keys[2]);
        }
        public BilPickBillDetail GetById(System.String pickBillCode, System.String stockCode, System.String planGoodsCode)
        {
            ICriteria criteria = Session.GetISession().CreateCriteria(typeof(BilPickBillDetail));

            criteria.Add(NHibernate.Criterion.Expression.Eq("PickBillCode", pickBillCode));
            criteria.Add(NHibernate.Criterion.Expression.Eq("StockCode", stockCode));
            criteria.Add(NHibernate.Criterion.Expression.Eq("PlanGoodsCode", planGoodsCode));

            BilPickBillDetail result = (BilPickBillDetail)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
        }

        #endregion
    }
}